Be more consistent with formatting of internal erros.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 13 Sep 2002 23:25:30 +0000 (23:25 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 13 Sep 2002 23:25:30 +0000 (23:25 +0000)
gpsbabel/csv.c
gpsbabel/gpsman.c
gpsbabel/gpsutil.c
gpsbabel/gpx.c
gpsbabel/magproto.c
gpsbabel/mapsource.c
gpsbabel/pcx.c
gpsbabel/psp.c
gpsbabel/tiger.c

index abfef221bc213540018fbc376a954166142845ea..c2cd9c4f97ab38243b1da9193aa5c1209f118feb 100644 (file)
 static FILE *file_in;
 static FILE *file_out;
 
+#define MYNAME "CSV"
+
 static void
 rd_init(const char *fname)
 {
        file_in = fopen(fname, "r");
        if (file_in == NULL) {
-               fatal("GPSUTIL: Cannot open %s for reading\n", fname);
+               fatal(MYNAME ": Cannot open %s for reading\n", fname);
        }
 }
 
@@ -46,7 +48,7 @@ wr_init(const char *fname)
 {
        file_out = fopen(fname, "w");
        if (file_out == NULL) {
-               fatal("GPSUTIL: Cannot open %s for writing\n", fname);
+               fatal(MYNAME ": Cannot open %s for writing\n", fname);
        }
 }
 
@@ -68,7 +70,7 @@ data_read(void)
                        &lat, &lon, desc) > 0) {
                wpt_tmp = calloc(sizeof(*wpt_tmp),1);
                if (wpt_tmp == NULL) {
-                       fatal("GPSMAN: cannot allocate memory\n");
+                       fatal(MYNAME ": cannot allocate memory\n");
                }
                while (*odesc == ' ' || *odesc == '\t') {
                        odesc++;
index e115e7d8276cdee08052727d983dc5962c15666e..c67f0af6d1afb777deaea87fe2be9a8989965b32 100644 (file)
 static FILE *in_file;
 static FILE *out_file;
 
+#define MYNAME "GPSMAN"
+
 static void
 gpsman_rd_init(const char *fname)
 {
        in_file = fopen(fname, "r");
        if (in_file == NULL) {
-               fatal("GPSMAN: Cannot open %s for reading\n", fname);
+               fatal(MYNAME ": Cannot open %s for reading\n", fname);
        }
 
 }
@@ -42,7 +44,7 @@ gpsman_wr_init(const char *fname)
 {
        out_file = fopen(fname, "w");
        if (out_file == NULL) {
-               fatal("GPSMAN: Cannot open %s for writing\n", fname);
+               fatal(MYNAME ": Cannot open %s for writing\n", fname);
        }
 
        fprintf(out_file, "!Format: DDD 1 WGS 84\n");
@@ -97,7 +99,7 @@ gpsman_read(void)
                wpt_tmp = calloc(sizeof(*wpt_tmp),1);
 
                if (wpt_tmp == NULL) {
-                       fatal("GPSMAN: Cannot allocate enough memory\n");
+                       fatal(MYNAME ": Cannot allocate enough memory\n");
                }
 
                lat = latm + latf;
index 1b046a128ed563e6745745b6527d00b036bde4c0..550d83113d7fe6a96878054d10b73a0c5235b4cf 100644 (file)
@@ -8,12 +8,14 @@
 static FILE *file_in;
 static FILE *file_out;
 
+#define MYNAME "GPSUTIL"
+
 static void
 rd_init(const char *fname)
 {
        file_in = fopen(fname, "r");
        if (file_in == NULL) {
-               fatal("GPSUTIL: Cannot open %s for reading\n", fname);
+               fatal(MYNAME ": Cannot open %s for reading\n", fname);
        }
 }
 
@@ -28,7 +30,7 @@ wr_init(const char *fname)
 {
        file_out = fopen(fname, "w");
        if (file_out == NULL) {
-               fatal("GPSUTIL: Cannot open %s for writing\n", fname);
+               fatal(MYNAME ": Cannot open %s for writing\n", fname);
        }
 }
 
@@ -55,7 +57,7 @@ data_read(void)
                        &alt, &alttype, desc, icon) > 0) {
                wpt_tmp = calloc(sizeof(*wpt_tmp),1);
                if (wpt_tmp == NULL) {
-                       fatal("GPSMAN: cannot allocate memory\n");
+                       fatal(MYNAME ": cannot allocate memory\n");
                }
                wpt_tmp->position.altitude.altitude_meters = alt;
                wpt_tmp->shortname = strdup(name);
index 58b84fefebf5e93e4757c870e13376d3bf545717..2c681ccaa81ab4840c67236cf3101615a4ba8610 100644 (file)
@@ -38,6 +38,8 @@ static waypoint *wpt_tmp;
 static FILE *fd;
 static FILE *ofd;
 
+#define MYNAME "GPX"
+
 static void
 tag_gpx(const char **attrv)
 {
@@ -60,7 +62,7 @@ tag_wpt(const char **attrv)
 
        wpt_tmp = calloc(sizeof(*wpt_tmp), 1);
        if (wpt_tmp == NULL) {
-               fatal("Can not allocate memory\n");
+               fatal(MYNAME ": allocate memory\n");
        }
 
        while (*avp) { 
@@ -157,11 +159,11 @@ gpx_rd_init(const char *fname)
 {
        fd = fopen(fname, "r");
        if (fd == NULL) {
-               fatal("GPX: Cannot open %s for reading\n", fname );
+               fatal(MYNAME ": Cannot open %s for reading\n", fname );
        }
        psr = XML_ParserCreate(NULL);
        if (!psr) {
-               fatal("GPX: Cannot create XML Parser\n");
+               fatal(MYNAME ": Cannot create XML Parser\n");
        }
        XML_SetElementHandler(psr, gpx_start, gpx_end);
        XML_SetCharacterDataHandler(psr, gpx_cdata);
@@ -178,7 +180,7 @@ gpx_wr_init(const char *fname)
 {
        ofd = fopen(fname, "w");
        if (ofd == NULL) {
-               fatal("GPX: Cannot open %s for writing\n", fname );
+               fatal(MYNAME ": open %s for writing\n", fname );
        }
 }
 
@@ -198,7 +200,7 @@ gpx_read(void)
                len = fread(buf, 1, sizeof(buf), fd);
                done = feof(fd); 
                if (!XML_Parse(psr, buf, len, done)) {
-                       fatal("GPX: XML parse error at %d: %s\n", 
+                       fatal(MYNAME ": XML parse error at %d: %s\n", 
                                XML_GetCurrentLineNumber(psr),
                                XML_ErrorString(XML_GetErrorCode(psr)));
                }
index a60a7a9bfa6ecf7537b997b098466c82e1e619dc..c84c0197f4d6c01a7383eba20c00d158cb79063b 100644 (file)
@@ -28,6 +28,7 @@
 #include "magellan.h"
 
 #define BAUDRATE B4800
+#define MYNAME "MAGPROTO"
 
 #if __WIN32__
 #include <windows.h>
@@ -248,7 +249,7 @@ mag_verparse(char *ibuf)
                        icon_mapping = map330_icon_table;
                        break;
                default:
-                       fatal("Magproto: Unknown receiver type.\n");
+                       fatal(MYNAME ": Unknown receiver type.\n");
        }
 }
 
@@ -267,7 +268,7 @@ mag_readmsg(void)
 
        if (!gr) {
                if (!got_version) {
-                       fatal("Magproto: No data received from GPS.\n");
+                       fatal(MYNAME ": No data received from GPS.\n");
                } else {
                        if (is_file)  {
                                found_done = 1;
@@ -293,7 +294,7 @@ if (debug_serial)
                fprintf(stderr, "RXERR %02x/%02x: '%s'\n", isum, mag_pchecksum(&ibuf[1],isz-5), ibuf);
                /* Special case receive errors early on. */
                if (!got_version) {
-                       fatal("Magproto: bad communication.  Check bit rate.\n");
+                       fatal(MYNAME ": bad communication.  Check bit rate.\n");
                }
        }
        if (debug_serial) {
@@ -343,7 +344,7 @@ terminit(const char *portname)
                          OPEN_EXISTING, 0, NULL);
 
        if (comport == INVALID_HANDLE_VALUE) {
-               fatal("Cannot open '%s'", portname);
+               fatal(MYNAME ": '%s'", portname);
        }
        tio.DCBlength = sizeof(DCB);
        GetCommState (comport, &tio);
@@ -367,7 +368,7 @@ terminit(const char *portname)
 
        if (!SetCommState (comport, &tio)) {
                CloseHandle(comport);
-               fatal("Unable to set port settings");
+               fatal(MYNAME ": set port settings");
        }
 
        GetCommTimeouts (comport, &timeout);
@@ -376,7 +377,7 @@ terminit(const char *portname)
        timeout.WriteTotalTimeoutConstant = 1000;
        if (!SetCommTimeouts (comport, &timeout)) {
                CloseHandle (comport);
-               fatal("Unable to set timeouts");
+               fatal(MYNAME ": set timeouts");
        }
 }
 
@@ -412,7 +413,7 @@ termwrite(char *obuf, int size)
 
        WriteFile (comport, obuf, size, &len, NULL);
        if (len != size) {
-               fatal("Write error.  Wrote %d of %d bytes.", len, size);
+               fatal(MYNAME ":.  Wrote %d of %d bytes.", len, size);
        }
 }
 
@@ -437,7 +438,7 @@ terminit(const char *portname)
         magfile_in = fopen(portname, "rb");
 
         if (magfile_in == NULL) {
-                fatal("Magproto: Cannot open %s.%s\n",
+                fatal(MYNAME ": Cannot open %s.%s\n",
                         portname, strerror(errno));
         }
 
@@ -505,7 +506,7 @@ mag_rd_init(const char *portname)
        while (!got_version) {
                mag_readmsg();
                if (time(NULL) > later) {
-                       fatal("Magproto: No acknowledgment from GPS on %s\n",
+                       fatal(MYNAME ": No acknowledgment from GPS on %s\n",
                                portname);
                }
        }
@@ -677,7 +678,7 @@ mag_wptparse(char *trkmsg)
 
        waypt  = calloc(sizeof *waypt, 1);
        if (waypt == NULL) 
-               fatal("Magproto: Cannot allocate memory\n");
+               fatal(MYNAME ": Cannot allocate memory\n");
 
        sscanf(trkmsg,"$PMGNWPL,%lf,%c,%lf,%c,%d,%c,%[^,],%[^,]", 
                &latdeg,&latdir,
index a1e7e7621e9392fb3c24b5b4cddb3cb13bb4cecf..da715d28728159ce36d5cbe260da115cefe9f954 100644 (file)
 static FILE *mapsource_file_in;
 static FILE *mapsource_file_out;
 
+#define MYNAME "MAPSOURCE" 
+
 static void
 mapsource_rd_init(const char *fname)
 {
        mapsource_file_in = fopen(fname, "r");
        if (mapsource_file_in == NULL) {
-               fatal("Cannot open '%s' for reading\n", fname);
+               fatal(MYNAME ": '%s' for reading\n", fname);
        }
 }
 
@@ -47,7 +49,7 @@ mapsource_wr_init(const char *fname)
 {
        mapsource_file_out = fopen(fname, "w");
        if (mapsource_file_out == NULL) {
-               fatal("Cannot open '%s' for writing\n", fname);
+               fatal(MYNAME ": '%s' for writing\n", fname);
                exit(1);
        }
 }
index 4cffcc017e639330c40675ad8d2517a16e90c3be..dfd45aa0a71b20d64700aeea6dfd6b9ab10f907a 100644 (file)
 static FILE *file_in;
 static FILE *file_out;
 
+#define MYNAME "PCX"
+
+
 static void
 rd_init(const char *fname)
 {
        file_in = fopen(fname, "r");
        if (file_in == NULL) {
-               fatal("GPSUTIL: Cannot open %s for reading\n", fname);
+               fatal(MYNAME ": Cannot open %s for reading\n", fname);
        }
 }
 
@@ -45,7 +48,7 @@ wr_init(const char *fname)
 {
        file_out = fopen(fname, "w");
        if (file_out == NULL) {
-               fatal("GPSUTIL: Cannot open %s for writing\n", fname);
+               fatal(MYNAME ": Cannot open %s for writing\n", fname);
        }
 }
 
index 19e8533f7dc9bb1ffec5dfd68c7988eab37d2e7a..c8a8f38fe11d15471deef2ec4f2d4db20c708966 100644 (file)
@@ -25,6 +25,8 @@
 #include <ctype.h>
 #include <math.h>  /* for M_PI */
 
+#define MYNAME "PSP"
+
 /*#define _DEBUG_PSP   1*/
 #define MAXPSPSTRINGSIZE       256
 #define MAXPSPOUTPUTPINS       8192   /* Any more points than this is ludicrous */
@@ -68,7 +70,7 @@ psp_rd_init(const char *fname)
 {
        psp_file_in = fopen(fname, "r");
        if (psp_file_in == NULL) {
-               fatal("PSP: Cannot open %s for reading\n", fname);
+               fatal(MYNAME ": Cannot open %s for reading\n", fname);
        }
 }
 
@@ -83,7 +85,7 @@ psp_wr_init(const char *fname)
 {
        psp_file_out = fopen(fname, "w");
        if (psp_file_out == NULL) {
-               fatal("PSP: Cannot open %s for writing\n", fname);
+               fatal(MYNAME ": Cannot open %s for writing\n", fname);
        }
 }
 
@@ -111,7 +113,7 @@ psp_read(void)
            wpt_tmp = calloc(sizeof(*wpt_tmp),1);
 
            if (wpt_tmp == NULL) {
-               fatal("PSP: cannot allocate memory\n");
+               fatal(MYNAME ": cannot allocate memory\n");
            }
 
            /* things we will probably never know about this waypoint */
@@ -163,7 +165,7 @@ psp_read(void)
            stringsize *= 2;
            
            if (stringsize > MAXPSPSTRINGSIZE) {
-               fatal("PSP: variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE);
+               fatal(MYNAME ": variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE);
            }
 
             /* stringsize bytes - string data */
@@ -184,7 +186,7 @@ psp_read(void)
            stringsize *= 2;
 
            if (stringsize > MAXPSPSTRINGSIZE) {
-               fatal("PSP: variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE);
+               fatal(MYNAME ": variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE);
            }
 
 #ifdef _DEBUG_PSP
@@ -208,7 +210,7 @@ psp_read(void)
            stringsize *= 2;
 
            if (stringsize > MAXPSPSTRINGSIZE) {
-               fatal("PSP: variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE);
+               fatal(MYNAME ": variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE);
            }
 
 
@@ -318,7 +320,7 @@ psp_write(void)
         s = waypt_count();
         
         if (s > MAXPSPOUTPUTPINS) {
-            fatal("attempt to output too many pushpins (%d).  The max is %d.  Sorry.\n", s, MAXPSPOUTPUTPINS);
+            fatal(MYNAME ": output too many pushpins (%d).  The max is %d.  Sorry.\n", s, MAXPSPOUTPUTPINS);
         }
 
         /* insert waypoint count into header */
index da611fc2638b62640097ef9256d95127c47c9300..5978153ebe18bfa3fad91bf0a2d47b957faa0001 100644 (file)
 static FILE *file_in;
 static FILE *file_out;
 
+#define MYNAME "GPSUTIL"
+
 static void
 rd_init(const char *fname)
 {
        file_in = fopen(fname, "r");
        if (file_in == NULL) {
-               fatal("GPSUTIL: Cannot open %s for reading\n", fname);
+               fatal(MYNAME ": Cannot open %s for reading\n", fname);
        }
 }
 
@@ -45,7 +47,7 @@ wr_init(const char *fname)
 {
        file_out = fopen(fname, "w");
        if (file_out == NULL) {
-               fatal("GPSUTIL: Cannot open %s for writing\n", fname);
+               fatal(MYNAME ": Cannot open %s for writing\n", fname);
        }
 }
 
@@ -73,7 +75,7 @@ abort();
                        &alt, &alttype, desc, icon) > 0) {
                wpt_tmp = calloc(sizeof(*wpt_tmp),1);
                if (wpt_tmp == NULL) {
-                       fatal("GPSMAN: cannot allocate memory\n");
+                       fatal(MYNAME ": cannot allocate memory\n");
                }
                wpt_tmp->position.altitude.altitude_meters = alt;
                wpt_tmp->shortname = strdup(name);